package com.xiaozhameng.threadlocal;

/**
 * ThreadLocal 测试
 */
public class ThreadLocalTest {

    private int temp = 0;

    public static void main(String[] args) {
        ThreadLocalTest demo = new ThreadLocalTest();

        ThreadLocal<String> threadLocal = new ThreadLocal<String>();

        for (int i = 0; i < 5; i++) {
            new Thread(() -> {
                threadLocal.set(Thread.currentThread().getName() + "的数据");
                System.out.println("-----------------------------------------");
                System.out.println(Thread.currentThread().getName() + "\t  " + threadLocal.get());
            }, String.valueOf(i)).start();
        }
    }
}
